import redis
import logging

class Config(object):
    """项目配置信息"""
    # mysql数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information17"
    SQLALCHEMY_TRACK_MODIFICATIONS = True

    # redis数据库配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    SECRET_KEY = "FAKSFJASKFFJKLAFNVZ?:l{21EMK1"

    # flask_session的配置信息
    SESSION_TYPE = "redis"  # 指定session 保存到redis中
    SESSION_USE_SIGNER = True  # 让cookie中的session_id 被加密签名处理
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)  # 使用redis的实例
    PERMANENT_SESSION_LIFETIME = 86400  # session的有效期,单位是秒

    # 默认日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    """开发阶段的项目配置信息"""
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产模式下的配置信息"""
    DEBUG = False
    LOG_LEVEL = logging.ERROR


config = {
    "development": DevelopmentConfig,
    "production": ProductionConfig
}
